//
//  MediaItem.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/2/28.
//

import Foundation
import UIKit
import CoreTransferable


// 视频类型（修正版 Transferable 实现）
struct Movie: Transferable {
    let url: URL
    
    static var transferRepresentation: some TransferRepresentation {
        FileRepresentation(contentType: .movie) { movie in
            SentTransferredFile(movie.url)
        } importing: { received in
            // ✅ 关键修正点：使用 received.file 访问文件
            let tempFile = URL.temporaryDirectory
                .appendingPathComponent(UUID().uuidString) // 唯一文件名
                .appendingPathExtension("mp4")
            
            try FileManager.default.copyItem(
                at: received.file   , // ✅ 正确访问方式
                to: tempFile
            )
            
            return Self(url: tempFile)
        }
    }
}

enum MediaType {
    case networkImage(String,String,Bool) //缩略图，地址，是否视频
    case localImage(UIImage)
    case localImagePath(String)
    case localVideo(URL)
}

//媒体，用于添加图片
struct MediaItem: Identifiable {
    let id = UUID()
    let type: MediaType
}
    
